package d1130.r2143num17;

import java.util.Scanner;

public class Demo05 {
    public static void main(String[] args) {
        System.out.println("请输入电话号码");
        Scanner sc = new Scanner(System.in);
        String phone = sc.next();
        if (checkPhoneNum(phone)){
            System.out.println("电话号码格式正确");
        }else{
            System.out.println("电话号码格式不正确");
        }
    }
        public static boolean checkPhoneNum (String str){
            boolean ret = true;
            if (str.length() != 11) {
                ret = false;
            } else {
                for (int i = 0; i < str.length(); i++) {
                   if( str.charAt(i) < 0 || str.charAt(i) > 9) {
                        ret = false;
                    }
                }

            }
            return ret;

        }}